WebSocketLinks

The links of site over WebSockets, to sites on any platform (JVM, Node.js, browsers): the links it accepts once it listens, and those it opens (connect). Each frame is a text message; those of a link arrive in order. The port listened on answers the plain HTTP requests for the pages it serves as well.

Constructors

Link copied to clipboard
constructor(site: LinkListener)

Properties

Link copied to clipboard

The page a plain HTTP GET of a path (as /join?x=1) is answered with, on the port listened on: none (null) for a request refused (404), as for every other request but those opening a WebSocket. Asked as each request comes.

Functions

Link copied to clipboard
open override fun close()

Closes every link, and stops listening

Link copied to clipboard
fun connect(uri: String, timeoutMillis: Long, code: String? = null, opening: (Link) -> Unit = {})

Opens a link to the site listening at uri (ws://host:port), waiting for it at most timeoutMillis: code presented if given (see Site.requiresCode), and the link given to opening before it opens

Link copied to clipboard
fun listen(port: Int = 0, host: String = "0.0.0.0"): Int

Accepts the links of other sites on port of host (an ephemeral port for 0): the port taken